import React, {Component} from 'react';
import {hot} from 'react-hot-loader/root';
import {connect} from 'dva';
import {Select} from 'antd';
const Option = Select.Option;

@connect(({global, manage}) => ({
    global,
    authority: global.authority,
    manage
}))
class RouteManage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            defaultAuthority: props.authority
        };
    }

    handleChange = val => {
        const {dispatch} = this.props;
        dispatch({
            type: 'global/updateUserInfo',
            data: {
                authority: val
            }
        }).then(() => {
            console.log(this.props);
        });
    };
    render() {
        return (
            <div className="bg-fff ui-p-15">
                <div className="flex just-center align-center">
                    <span className="f14">权限模拟：</span>
                    <Select
                        defaultValue={this.state.defaultAuthority}
                        style={{width: 120}}
                        onChange={this.handleChange}
                    >
                        <Option value={1}>管理员</Option>
                        <Option value={2}>用户</Option>
                        <Option value={3}>访客</Option>
                    </Select>
                </div>
            </div>
        );
    }
}
export default hot(RouteManage);
